package map;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class MaoTest4 {
    public static void main(String[] args) {
        Map<String, Double> map = new HashMap<>();
        map.put("牛魔王", 175.4);
        map.put("至尊宝", 182.5);
        map.put("紫霞", 168.7);
        map.put("蜘蛛精", 165.4);
        System.out.println(map);

        // 调用map集合中的entryset方法，把map类型集合转化为set类型
        Set<Map.Entry<String, Double>> entries = map.entrySet();
        for (Map.Entry<String, Double> entry : entries) {
            String key = entry.getKey();
            double value = entry.getValue();
            System.out.println(key + "->" + value);
        }
        System.out.println("----------------------------------------------");
        map.forEach((k, v) -> {
            System.out.println(k + "->" + v);
        });
    }
}
